<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app->get('/', function () use ($app) {
    return $app->version();
});
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', ['middleware' => 'auth:api'], function () use ($api) {

    $api->get('products', 'App\Http\Controllers\Product\ProductController@products');
    $api->get('product/{id}', 'App\Http\Controllers\Product\ProductController@product');

    $api->get('shops', 'App\Http\Controllers\Shop\ShopController@shops');
    $api->post('shops/{id}', 'App\Http\Controllers\Shop\ShopController@editShop');
    $api->get('shop/{id}', 'App\Http\Controllers\Shop\ShopController@shop');
    $api->get('shop/{id}/comments', 'App\Http\Controllers\Shop\ShopController@comments');
    $api->post('shop/comment/', 'App\Http\Controllers\Shop\ShopController@addComment');
    $api->post('shopManagers', 'App\Http\Controllers\Shop\ShopController@addManager');
    $api->get('shopManagers', 'App\Http\Controllers\Shop\ShopController@managers');
    $api->put('shopManagers/{id}', 'App\Http\Controllers\Shop\ShopController@editManager');
    $api->post('shop/application', 'App\Http\Controllers\Shop\ShopController@applyShop');//已废弃
    $api->post('shop/manager/application', 'App\Http\Controllers\Shop\ShopController@applyManager');//已废弃
    $api->put('shop/{id}/view', 'App\Http\Controllers\Shop\ShopController@addView');
    $api->post('shop/{id}/fav', 'App\Http\Controllers\Shop\ShopController@fav');
    $api->get('shops/{id}/businessData', 'App\Http\Controllers\Shop\ShopController@business');
    $api->post('shops/{id}/coupon', 'App\Http\Controllers\Shop\ShopController@addCoupon');
    $api->get('shops/{id}/coupons', 'App\Http\Controllers\Shop\ShopController@coupons');
    $api->get('shopCoupons/{id}', 'App\Http\Controllers\Shop\ShopController@coupon');
    $api->post('shopCoupons/{id}', 'App\Http\Controllers\Shop\ShopController@editCoupon');
    $api->delete('shopCoupons/{id}', 'App\Http\Controllers\Shop\ShopController@disableCoupon');
    $api->get('shopCouponPurchases', 'App\Http\Controllers\Shop\ShopController@couponPurchases');
    $api->get('shopCouponPurchases/{code}', 'App\Http\Controllers\Shop\ShopController@couponPurchase');
    $api->put('shopCouponPurchases/{code}/verification', 'App\Http\Controllers\Shop\ShopController@verifyCouponPurchase');
    $api->post('shops/{id}/HB', 'App\Http\Controllers\HongBao\HongBaoController@ShopHB');
    $api->get('shops/{id}/girls', 'App\Http\Controllers\Shop\ShopController@girls');
    $api->post('shops/{id}/girls', 'App\Http\Controllers\Shop\ShopController@addGirls');
    $api->post('girls/{id}', 'App\Http\Controllers\Shop\ShopController@editGirls');

    $api->get('im/friends', 'App\Http\Controllers\IM\IMController@friends');
    $api->get('im/groups/{id}/members', 'App\Http\Controllers\IM\IMController@groupMembers');
    $api->get('im/groups', 'App\Http\Controllers\IM\IMController@allGroups');
    $api->post('im/groups', 'App\Http\Controllers\IM\IMController@addGroup');

    $api->post('user', 'App\Http\Controllers\Auth\UserController@edit');
    $api->put('users/{id}/adminEdit', 'App\Http\Controllers\Auth\UserController@adminEdit');
    $api->put('users/{id}/agentEdit', 'App\Http\Controllers\Auth\UserController@agentEdit');
    $api->get('users/{id}', 'App\Http\Controllers\Auth\UserController@detail');
    $api->get('users', 'App\Http\Controllers\Auth\UserController@users');
    $api->get('user/nickname/validation', 'App\Http\Controllers\Auth\UserController@checkNickname');
    $api->post('user/address', 'App\Http\Controllers\Auth\UserController@addAddress');
    $api->get('user/address', 'App\Http\Controllers\Auth\UserController@getAddresses');
    $api->put('user/address/{id}', 'App\Http\Controllers\Auth\UserController@editAddress');
    $api->delete('user/address/{id}', 'App\Http\Controllers\Auth\UserController@deleteAddress');
    $api->put('user/address/default/{id}', 'App\Http\Controllers\Auth\UserController@setDefaultAddress');
    $api->get('user/{id}/statistic', 'App\Http\Controllers\Auth\UserController@getUserSta');
    $api->get('user/{id}/follow', 'App\Http\Controllers\Auth\UserController@getFollow');
    $api->get('user/{id}/follower', 'App\Http\Controllers\Auth\UserController@getFollower');
    $api->get('user/productPurchase', 'App\Http\Controllers\Product\ProductController@productPurchase');
    $api->post('users/{id}/report', 'App\Http\Controllers\Auth\UserController@report');
    $api->get('recFriends', 'App\Http\Controllers\Auth\UserController@recFriends');
    $api->put('users/paymentPassword', 'App\Http\Controllers\Auth\UserController@setPaymentPw');

    $api->get('circles', 'App\Http\Controllers\Circle\CircleController@circles');
    $api->post('circles', 'App\Http\Controllers\Circle\CircleController@addCircle');
    $api->delete('circles/{id}', 'App\Http\Controllers\Circle\CircleController@deleteCircle');

    $api->post('follow/{id}', 'App\Http\Controllers\Auth\UserController@follow');
    $api->post('blackList/{id}', 'App\Http\Controllers\Auth\UserController@blackList');

    $api->get('posts', 'App\Http\Controllers\Post\PostController@posts');
    $api->get('post/{id}', 'App\Http\Controllers\Post\PostController@post');
    $api->get('post/{id}/comments', 'App\Http\Controllers\Post\PostController@comments');
    $api->get('post/{id}/praises', 'App\Http\Controllers\Post\PostController@praises');
    $api->post('post', 'App\Http\Controllers\Post\PostController@addPost');
    $api->post('post/{id}/comment', 'App\Http\Controllers\Post\PostController@addComment');
    $api->post('post/{id}/buy/hongBao', 'App\Http\Controllers\Post\PostController@buyWithHongBao');
    $api->post('post/{id}/praise', 'App\Http\Controllers\Post\PostController@praise');
    $api->put('post/{id}/view', 'App\Http\Controllers\Post\PostController@addView');
    $api->post('post/{id}/shared', 'App\Http\Controllers\Tool\ToolController@shared');
    $api->post('post/{id}/fav', 'App\Http\Controllers\Post\PostController@fav');
    $api->post('post/{id}/report', 'App\Http\Controllers\Post\PostController@report');
    $api->post('post/{id}/disable', 'App\Http\Controllers\Post\PostController@disablePost');//废弃
    $api->put('post/{id}/disable', 'App\Http\Controllers\Post\PostController@disablePost');//废弃
    $api->delete('posts/{id}', 'App\Http\Controllers\Post\PostController@disablePost');
    $api->put('posts/{id}/public', 'App\Http\Controllers\Post\PostController@editPublic');
    $api->get('posts/comments/{id}', 'App\Http\Controllers\Post\PostController@comment');
    $api->delete('posts/comments/{id}', 'App\Http\Controllers\Post\PostController@disableComment');

    $api->get('hongBaos', 'App\Http\Controllers\HongBao\HongBaoController@HongBaos');

    $api->get('banners', 'App\Http\Controllers\Banner\BannerController@banners');

    $api->get('msg/statistic', 'App\Http\Controllers\Msg\MsgController@sta');
    $api->get('msg/comment', 'App\Http\Controllers\Msg\MsgController@comment');
    $api->get('msg/praise', 'App\Http\Controllers\Msg\MsgController@praise');
    $api->get('msg/system', 'App\Http\Controllers\Msg\MsgController@system');

    $api->get('tool/shareData', 'App\Http\Controllers\Tool\ToolController@shareData');
    $api->post('tool/feedback', 'App\Http\Controllers\Tool\ToolController@feedback');
    $api->get('tool/locationToDistrict', 'App\Http\Controllers\Tool\ToolController@locationToDistrict');

    $api->post('payment/ali/orderInfo', 'App\Http\Controllers\Payment\AliPayController@orderInfo');
    $api->post('payment/ali/refund', 'App\Http\Controllers\Payment\AliPayController@refund');
//    $api->post('payment/ali/trans', 'App\Http\Controllers\Payment\AliPayController@trans');
    $api->post('payment/wechat/preOrder', 'App\Http\Controllers\Payment\WeChatPayController@preOrder');
    $api->post('payment/wechat/refund', 'App\Http\Controllers\Payment\WeChatPayController@refund');
//    $api->post('payment/wechat/trans', 'App\Http\Controllers\Payment\WeChatPayController@trans');
    $api->post('payment/IOS/orderInfo', 'App\Http\Controllers\Payment\IOSController@orderInfo');
    $api->post('payment/IOS/notify', 'App\Http\Controllers\Payment\IOSController@notify');
    $api->post('payment/balance', 'App\Http\Controllers\Payment\BalanceController@balance');
    $api->post('payment/balance/refund', 'App\Http\Controllers\Payment\BalanceController@refund');
    $api->get('payment/orders', 'App\Http\Controllers\Payment\OrderController@orders');
    $api->put('payment/orders/{id}', 'App\Http\Controllers\Payment\OrderController@edit');
    $api->get('balances/{id}', 'App\Http\Controllers\Payment\BalanceController@balances');

    $api->post('booked', 'App\Http\Controllers\Booked\BookedController@add');
    $api->get('booked', 'App\Http\Controllers\Booked\BookedController@booked');
    $api->put('booked/{id}', 'App\Http\Controllers\Booked\BookedController@edit');

    $api->post('MLMRelates', 'App\Http\Controllers\MLM\MLMController@addRelate');
    $api->get('MLMRelates', 'App\Http\Controllers\MLM\MLMController@relates');
    $api->get('MLMChildren', 'App\Http\Controllers\MLM\MLMController@children');
    $api->get('MLMProfit', 'App\Http\Controllers\MLM\MLMController@profit');
    $api->get('MLMBalanceLogs', 'App\Http\Controllers\MLM\MLMController@balanceLogs');

    $api->get('tags', 'App\Http\Controllers\Tag\TagController@tags');

    $api->post('shopWithdrawApplies', 'App\Http\Controllers\Withdraw\WithdrawController@addShopApply');
    $api->post('userWithdrawApplies', 'App\Http\Controllers\Withdraw\WithdrawController@addUserApply');

    $api->get('inviteCode', 'App\Http\Controllers\Invite\InviteController@inviteCode');
    $api->post('invite/{code}', 'App\Http\Controllers\Invite\InviteController@invite');

});
$api->version('v1', [], function () use ($api) {
    $api->get('stats', function(){
//        return \App\Libraries\Easemob\Easemob::singleton()->showFriends('6F9C3BFC39DA59B6C03ACA12E1FE1BE4');
//        return md5('6F9C3BFC39DA59B6C03ACA12E1FE1BE4');
    });
    $api->post('login', 'App\Http\Controllers\Auth\LoginController@login');
    $api->post('reg', 'App\Http\Controllers\Auth\LoginController@reg');
    $api->post('guest', 'App\Http\Controllers\Auth\LoginController@guest');
    $api->put('user/password', 'App\Http\Controllers\Auth\UserController@setPassword');

    $api->get('api', 'App\Http\Controllers\API\APIController@api');
    $api->get('getDianPingShopIds', 'App\Http\Controllers\API\APIController@getDianPingShopIds');
    $api->get('getDianPingShopInfo', 'App\Http\Controllers\API\APIController@getDianPingShopInfo');
    $api->get('collectDianPingShop', 'App\Http\Controllers\API\APIController@collectDianPingShop');
    $api->get('locationToAddress', 'App\Http\Controllers\API\APIController@locationToAddress');
    $api->get('baiduToTencentLocations', 'App\Http\Controllers\API\APIController@baiduToTencentLocations');
    $api->get('collectHZLMShop', 'App\Http\Controllers\API\APIController@collectHZLMShop');
    $api->get('locationToAddressForHZLM', 'App\Http\Controllers\API\APIController@locationToAddressForHZLM');
    $api->get('coordinateToAddress', 'App\Http\Controllers\API\APIController@coordinateToAddress');
    $api->get('coordinateToAddressDetail/{id}', 'App\Http\Controllers\API\APIController@coordinateToAddressDetail');
    $api->get('addFriends/{from}/{to}', 'App\Http\Controllers\API\APIController@addFriends');
    $api->get('sendMsg', 'App\Http\Controllers\API\APIController@sendMsg');
    $api->get('createUser', 'App\Http\Controllers\API\APIController@createUser');
    $api->get('createBot', 'App\Http\Controllers\API\APIController@createdBot');
    $api->get('changePost', 'App\Http\Controllers\API\APIController@changePost');
    $api->get('districtFirstLetter', 'App\Http\Controllers\API\APIController@districtFirstLetter');
    $api->get('jobTest', 'App\Http\Controllers\API\APIController@jobTest');
    $api->get('testCache', 'App\Http\Controllers\API\APIController@testCache');
    $api->get('testValidator', 'App\Http\Controllers\API\APIController@testValidator');
    $api->get('changeEasemobNickname', 'App\Http\Controllers\API\APIController@changeEasemobNickname');
    $api->get('getGroup', 'App\Http\Controllers\API\APIController@getGroup');
    $api->get('getMobileCityId', 'App\Http\Controllers\API\APIController@getMobileCityId');
    $api->get('spiderForJWQNW', 'App\Http\Controllers\API\APIController@spiderForJWQNW');
    $api->get('createInviteCode', 'App\Http\Controllers\API\APIController@createInviteCode');
    $api->get('testWhatEverINeed', 'App\Http\Controllers\API\APIController@testWhatEverINeed');

    $api->get('shopSta', 'App\Http\Controllers\API\CronController@shopSta');
    $api->get('couponSta', 'App\Http\Controllers\API\CronController@couponSta');
    $api->get('postSta', 'App\Http\Controllers\API\CronController@postSta');
    $api->get('postReportSta', 'App\Http\Controllers\API\CronController@postReportSta');
    $api->get('checkVIP', 'App\Http\Controllers\API\CronController@checkVIP');
    $api->get('deleteDeadUsers', 'App\Http\Controllers\API\CronController@deleteDeadUsers');
    $api->get('balance', 'App\Http\Controllers\API\CronController@balance');
    $api->get('shopHasHB', 'App\Http\Controllers\API\CronController@shopHasHB');
    $api->get('cityStatistics', 'App\Http\Controllers\API\CronController@cityStatistics');
    $api->get('shopWithdrawBatch', 'App\Http\Controllers\API\CronController@shopWithdrawBatch');
    $api->get('userWithdrawBatch', 'App\Http\Controllers\API\CronController@userWithdrawBatch');
    $api->get('userPointBatch', 'App\Http\Controllers\API\CronController@userPointBatch');

    $api->get('tool/version', 'App\Http\Controllers\Tool\ToolController@version');
    $api->get('tool/district', 'App\Http\Controllers\Tool\ToolController@district');
    $api->get('tool/statisticsData', 'App\Http\Controllers\Tool\ToolController@statisticsData');
    $api->get('tool/publicCities', 'App\Http\Controllers\Tool\ToolController@publicCities');

    $api->post('payment/ali/notify', 'App\Http\Controllers\Payment\AliPayController@notify');
    $api->post('payment/wechat/notify', 'App\Http\Controllers\Payment\WeChatPayController@notify');

    $api->post('codeToSession', 'App\Http\Controllers\MiniProgram\MiniProgramController@codeToSession');
    $api->post('decryptData', 'App\Http\Controllers\MiniProgram\MiniProgramController@decryptData');
});

$api->version('v1', ['middleware' => ['cros:api', 'api.throttle']], function () use ($api)
{
    $api->post('hongbao', 'App\Http\Controllers\HongBao\HongBaoController@add');
    $api->options('hongbao', 'App\Http\Controllers\HongBao\HongBaoController@add');
    $api->post('sms', 'App\Http\Controllers\Auth\LoginController@sendSMS');
    $api->post('MLMInvite', 'App\Http\Controllers\MLM\MLMController@invite');
});



$api->version('v2', ['middleware' => 'auth:api'], function () use ($api) {
    $api->get('shops', 'App\Http\Controllers\V2\Shop\ShopController@shops');
    $api->post('shops/application', 'App\Http\Controllers\V2\Shop\ShopController@applyShop');
    $api->post('shops/managers', 'App\Http\Controllers\V2\Shop\ShopController@addManager');
    $api->get('shopCouponPurchases', 'App\Http\Controllers\V2\Shop\ShopController@couponPurchases');
    $api->get('shopCouponPurchases/{code}', 'App\Http\Controllers\V2\Shop\ShopController@couponPurchase');
    $api->get('payment/orders', 'App\Http\Controllers\V2\Payment\OrderController@orders');
});
//$api = app('api.router');